<template>
  <div style="text-align: left">
    <el-container>
      <el-header class="layout-header">
        <div style="position: absolute;top: 10px">
          <el-avatar :src="community.communityIcon" size="20"></el-avatar>
        </div>
        <h3 style="margin-top: 15px;font-size: 20px;margin-left: 50px" >疫点通-{{community.communityName}}
          <span style="float: right;font-size: 15px">
             <div style="position: absolute; right: 250px;top: 10px">
            <el-avatar :src="admin.netIcon" size="20"></el-avatar>
          </div>
            {{admin.netName}} &nbsp;({{admin.isManager}})
            &nbsp; &nbsp; &nbsp;
                    <a href="javascript:void(0)" @click="logout()">退出登录</a>
                </span>
        </h3>

      </el-header>
      <el-container class="layout-body">
        <el-aside class="layout-aside">
          <el-menu
              router="true"
              class="el-menu-vertical-demo"
              unique-opened="true"
              background-color="#545c64"
              text-color="#fff"
              active-text-color="#55a1ff">
            <el-menu-item index="/admin/index">
              <template slot="title">
                <i style="font-size:20px" class="fa fa-user-circle"></i>
                &nbsp;
                <span>主页</span>
              </template>
            </el-menu-item>
            <el-submenu index="/admin" :disabled="this.judge">
              <template slot="title">
                <i style="font-size:20px" class="fa fa-user-circle"></i>
                &nbsp;
                <span>网格员管理</span>
              </template>
              <el-menu-item index="/admin/list" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                &nbsp;
                <span>网格员列表</span>
              </el-menu-item>
              <el-menu-item index="/admin/add">
                <i style="font-size: 15px" class="fa fa-sign-in"></i>
                &nbsp;
                <span>添加网格员</span>
              </el-menu-item>
              <el-menu-item index="/admin/update">
                <i style="font-size: 15px" class="fa fa-pencil-square-o"></i>
                &nbsp;
                <span>修改网格员信息</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="/user" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-address-book-o"></i>
                &nbsp;
                <span>居民管理</span>
              </template>
              <el-menu-item index="/admin/user/list">
                <i style="font-size: 15px" class="fa fa-list"></i>
                &nbsp;
                <span>居民列表</span>
              </el-menu-item>

            </el-submenu>
            <el-submenu index="/out" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-fighter-jet"></i>
                &nbsp;
                <span>外出管理</span>
              </template>
              <el-menu-item index="/admin/out/list" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                &nbsp;
                <span>外出列表</span>
              </el-menu-item>
              <el-menu-item index="/admin/out/check/list" >
                <i style="font-size: 15px" class="fa fa-check-square-o"></i>
                &nbsp;
                <span>待审核列表</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="/acid" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-thermometer-half"></i>
                &nbsp;
                <span>核酸检测</span>
              </template>
<!--              <el-menu-item index="/admin/appointment" >-->
<!--                <i style="font-size: 15px" class="fa fa-list"></i>-->

<!--                <span>预约核酸列表</span>-->
<!--              </el-menu-item>-->
<!--              <el-menu-item index="/admin/select">-->
<!--                <i style="font-size: 15px" class="fa fa-list"></i>-->

<!--                <span>查询结果</span>-->
<!--              </el-menu-item>-->
              <el-menu-item index="/admin/select/all" >
                <i style="font-size: 15px" class="fa fa-check-square-o"></i>
                &nbsp;
                <span>已通过列表</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="/admin/sign" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-map-marker"></i>
                &nbsp;
                <span>打卡管理</span>
              </template>
              <el-menu-item index="/admin/sign/list" >
                <i style="font-size: 15px" class="fa fa-check-square-o"></i>
                &nbsp;
                <span>用户打卡信息</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="/vegetable" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-cutlery"></i>
                &nbsp;
                <span>购物管理</span>
              </template>

              <el-menu-item index="/admin/vegetable/list" >
                <i style="font-size: 15px" class="fa fa-cutlery"></i>
                &nbsp;
                <span>商品列表</span>
              </el-menu-item>
              <el-menu-item index="/admin/vegetable/add" >
                <i style="font-size: 15px" class="fa fa-check-square-o"></i>
                &nbsp;
                <span>添加商品</span>
              </el-menu-item>
              <el-menu-item index="/admin/order/list" >
                <i style="font-size: 15px" class="fa fa-shopping-bag"></i>
                &nbsp;
                <span>订单列表</span>
              </el-menu-item>
            </el-submenu>


            <el-submenu index="/notice" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-bell-o"></i>
                &nbsp;
                <span>通知管理</span>
              </template>
              <el-menu-item index="/admin/notice/list" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                &nbsp;
                <span>已发布通知列表</span>
              </el-menu-item>
              <el-menu-item index="/admin/notice/add" >
                <i style="font-size: 15px" class="fa fa-check-square-o"></i>
                &nbsp;
                <span>发布通知</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="/qrCode" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-qrcode"></i>
                &nbsp;
                <span>通行码</span>
              </template>
              <el-menu-item index="/admin/qr/show" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                <span>通行码生成</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="/volunteer" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-plus-square "></i>
                &nbsp;
                <span>志愿者管理</span>
              </template>
              <el-menu-item index="/admin/volunteer/volunteerApply" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                <span>申请列表</span>
              </el-menu-item>

              <el-menu-item index="/admin/volunteer/volunteerList" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                <span>志愿者列表</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="/work" >
              <template slot="title">
                <i style="font-size: 20px" class="fa fa-file-word-o"></i>
                &nbsp;
                <span>任务管理</span>
              </template>
              <el-menu-item index="/admin/work/give" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                &nbsp;
                <span>分配列表</span>
              </el-menu-item>

              <el-menu-item index="/admin/work/list-by-work" >
                <i style="font-size: 15px" class="fa fa-list"></i>
                <span>所有任务</span>
              </el-menu-item>
            </el-submenu>


          </el-menu>
        </el-aside>

        <el-main>
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import {getNetInfo} from "@/api/admin_api";

import {getSimpleCommunity} from "@/api/admin_api";
import {removeToken} from "@/utils/Token";

export default {
  name: "admin-main",
  data(){
    return{
        admin:{
          netName:'王艺洁',
          netIcon:require('../assets/adminAvatar.jpeg'),
        },
      community:{
        communityName:'',
        communityIcon:require('../assets/communityIcon.jpeg'),
      },
      judge:''
    };
  },
  created() {
    getNetInfo().then((res) => {
      this.admin = res.data.data;
      if (this.admin.isManager){
        this.admin.isManager = "区域负责人"
        this.judge = false
      }else {
        this.judge = true
        this.admin.isManager = "网格管理员"
      }
    })

    getSimpleCommunity().then((res) => {
      this.community = res.data.data
    })


  },
  methods: {
    logout(){
      this.$router.push('/')
      removeToken('token')
    }

  }
}
</script>

<style scoped>
* {
  margin: 0;
}
.layout-header {
  background: #2c3e50;
  color: #fff;
}
.layout-body {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
}
.layout-aside {
  background: dimgray;
  color: #fff;
}
</style>